/*
 *  Copyright 2019-2020 Zheng Jie
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.fzhucc.modules.wxApplet.controller;

import com.fzhucc.annotation.Log;
import com.fzhucc.annotation.rest.AnonymousGetMapping;
import com.fzhucc.annotation.rest.AnonymousPostMapping;
import com.fzhucc.modules.wxApplet.domain.ChangeRandomDto;
import com.fzhucc.modules.wxApplet.domain.WxAppletQueryCriteria;
import com.fzhucc.modules.wxApplet.domain.WxPhoneCriteria;
import com.fzhucc.modules.wxApplet.domain.WxZqxCriteria;
import com.fzhucc.modules.wxApplet.service.WxAppletService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @author yyg
 * @date 2022-11-21
 */
@RestController
@RequiredArgsConstructor
@Api(tags = "微信小程序:接口")
@RequestMapping("/api/wx/applet")
public class WxAppletController {

    private final WxAppletService wxAppletService;


    @Log("查询用户分类类型")
    @ApiOperation("查询用户分类类型")
    @GetMapping("/getUserType")
    public ResponseEntity<Object> getUserType() {
        return new ResponseEntity<>(wxAppletService.findAllUserType(), HttpStatus.OK);
    }


    @Log("根据用户type_id查询")
    @ApiOperation("根据用户type_id查询")
    @GetMapping("/getTypeByTypeId")
    public ResponseEntity<Object> getTypeByTypeId(WxAppletQueryCriteria criteria) {
        return new ResponseEntity<>(wxAppletService.findTypeByTypeId(criteria), HttpStatus.OK);
    }

    @Log("微信我的页面进来查询 个人项目的项目库变化消息")
    @ApiOperation("微信我的页面进来查询 个人项目的项目库变化消息")
    @PostMapping("/getProjectNoticeWithWxUser")
    public ResponseEntity<Object> getProjectNoticeWithWxUser() {
        return new ResponseEntity<>(wxAppletService.getProjectNoticeWithWxUser(), HttpStatus.OK);
    }


    @PostMapping("getPhone")
    @Log("获取手机号")
    @ApiOperation("获取手机号")
    public ResponseEntity<Object> getPhone(@RequestBody WxPhoneCriteria criteria) {
        wxAppletService.getPhone(criteria);
        return new ResponseEntity<>(HttpStatus.OK);
    }

    @PostMapping("getPhoneResp")
    @Log("获取手机号返回手机号值")
    @ApiOperation("获取手机号返回手机号值")
    public ResponseEntity<Object> getPhoneResp(@RequestBody WxPhoneCriteria criteria) {
        return new ResponseEntity<>(wxAppletService.getPhoneResp(criteria), HttpStatus.OK);
    }

    @Log("换一换  只有3个的推荐服务的话还是随机原来3个")
    @ApiOperation("换一换  只有3个的推荐服务的话还是随机原来3个")
    @AnonymousPostMapping("/getChangeRandom")
    public ResponseEntity<Object> getChangeRandom(@RequestBody ChangeRandomDto changeRandomDto) {
        return new ResponseEntity<>(wxAppletService.getChangeRandom(changeRandomDto), HttpStatus.OK);
    }


    @AnonymousGetMapping("getAppIndexData")
    @Log("获取h5、小程序首页劳模工匠数、企业需求数")
    @ApiOperation("获取h5、小程序首页劳模工匠数、企业需求数")
    public ResponseEntity<Object> getAppIndexData(WxZqxCriteria criteria) {
        return new ResponseEntity<>(wxAppletService.getAppIndexData(criteria), HttpStatus.OK);
    }

}